package com.fis.vaadin.component;

import java.util.ArrayList;
import java.util.List;

import com.vaadin.terminal.Resource;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.MenuBar.MenuItem;

public class FMenuItem extends MenuBar.MenuItem
{
	private MenuBar parentMenu;
	private String name;
	private final List<MenuItem> itsChildren;

	public FMenuItem(MenuBar menuBar, String caption, Resource icon,
			FCommand command)
	{
		menuBar.super(caption, icon, command);
		parentMenu = menuBar;
		itsChildren = super.getChildren();
		name = caption;
	}
	
	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

//	public void addItem(MenuBar.MenuItem item) throws IllegalStateException
//	{
//		if (itsChildren == null)
//		{
//			super.addItem(item.getText(), item.getIcon(), item.getCommand());
//		}
//		
//		if (isSeparator())
//		{
//			throw new UnsupportedOperationException(
//					"Cannot add items to a separator");
//		}
//		if (isCheckable())
//		{
//			throw new IllegalStateException(
//					"A checkable item cannot have children");
//		}
//		
//		if (itsChildren == null)
//		{
//			itsChildren = new ArrayList<MenuItem>();
//		}
//		
//		// The only place where the parent is set
////		item.setParent(this);
//		itsChildren.add(item);
//		
//		parentMenu.requestRepaint();
//	}
	
//	protected setParent
}
